<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h4 align="center">合同详情</h4>
	<table border="1" cellspacing="0" cellpadding="3" align="center">
		
		<c:choose>
			<c:when test="${empty requestScope.contractDetails}">
				<td>暂无数据</td>
			</c:when>
			<c:otherwise>
				<tr>
					<th>ID</th>
					<th>商品</th>
					<th>单价</th>
					<th>数量</th>
					<th>合计</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${requestScope.contractDetails}" var="d">
					<c:set var="s" value="${d.states}"/>
					<tr>
						<td>${d.detailId}</td>
						<td>${d.goodsName }</td>
						<td>${d.price }</td>
						<td>${d.shopNum }</td>
						<td>${d.sum }</td>
						<c:choose>
							<c:when test="${s==0 }">
								<td>
									<a href="${pageContext.request.contextPath }/contract/buildBills/${d.detailId}">生成发货单</a>
								</td>
								<td>
							<a href="${pageContext.request.contextPath }/detail/deleteDetails/${d.detailId}">删除</a>
						</td>
							</c:when>
							<c:when test="${s==1 }">
								<td>待发货</td>
							</c:when>
							<c:when test="${s==2 }">
								<td>已发货</td>
							</c:when>
						</c:choose>
					</tr>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	</table>
	<h4 align="center">
		<c:choose>
			<c:when test="${empty requestScope.contractDetails}">
				<td>总计:0元</td>
			</c:when>
			<c:otherwise>
				<c:forEach items="${requestScope.contractDetails}" var="d" begin="0" end="0">
			   		<c:out value="总计: ${d.money}元"/>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	</h4>
	${requestScope.NotEnough }
	<table align="center">
		<tr>
			<c:set scope="session" value="${requestScope.contract.states }" var="st"></c:set>
			<c:choose>
				<c:when test="${st == '未履行' }">
					<td>
						<form action="${pageContext.request.contextPath }/detail/inputDetails/${contract.contractId}" method="get"
						 style="width: 90%; margin: auto">
						<input type="submit" value="录入">
						</form>
					</td>
				</c:when>
				<c:when test="${st != '未履行' }">
					<h4 align="center">该合同不支持录入</h4>
				</c:when>
			</c:choose>
			<td>
				<form action="${pageContext.request.contextPath }/contract/list" method="get"
				 style="width: 90%; margin: auto">
					<input type="submit" value="返回">
				</form>
			</td>
		</tr>
	</table>
</body>
</html>